<template>
	<view>
		<view class="more" v-for="(item,index) in list">
			<image :src="$wanlshop.oss(item.goods_image, 255, 255)" mode="aspectFill"></image>
			<view class="detail">
				<view class="conment">
					<view class="head">{{item.goods_name}}</view>
					<view class="name">{{item.manufacturer}}</view>
				</view>
				<view class="foot">
					<view class="reservation" @click="purchasingForm(item)">预约</view>
				</view>
			</view>
		</view>
		<view v-if="list.length === 0" class="empty-state">
			<image :src="common.appUrl.oss+common.imgList.wulist" mode="aspectFill"></image>
			<view class="empty-text">暂无数据</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				search_text: '',
				list: []
			}
		},
		computed: {
			...mapState(['common'])
		},
		onLoad(option) {
			this.search_text = option.search_text
			console.log(this.search_text);
			this.getXinGoods()
		},
		methods: {
			async getXinGoods() {
				await uni.request({
					url: '/wanlshop/product/getXinGoods',
					data: {
						"search": this.search_text
					},
					method: 'GET',
					success: res => {
						this.list = res.data
					}
				});
			},
			purchasingForm(item) {
				let itemStr = encodeURIComponent(JSON.stringify(item));
				uni.navigateTo({
					url: `/pages/new/purchasingForm/purchasingForm?xinte_goods=${itemStr}`
				})
			},
		}
	}
</script>

<style lang="scss">
	.more {
		width: 690rpx;
		display: flex;
		align-items: center;
		margin-left: 30rpx;
		margin-top: 30rpx;
		background-color: #fff;
		border-radius: 16rpx;
		padding: 30rpx 0;

		image {
			width: 182rpx;
			height: 182rpx;
			border-radius: 16rpx;
			margin-left: 30rpx;
		}

		.detail {
			width: 428rpx;
			height: 162rpx;
			margin-left: 20rpx;
			display: flex;
			flex-wrap: wrap;
			align-content: space-between;

			.conment {
				width: 100%;

				.head {
					width: 100%;
					font-size: 26rpx;
					color: #333333;
				}

				.name {
					width: 100%;
					font-size: 24rpx;
					color: #999999;
					margin-top: 10rpx;
				}
			}

			.foot {
				width: 100%;
				display: flex;
				justify-content: flex-end;

				.reservation {
					width: 110rpx;
					height: 52rpx;
					border-radius: 50rpx;
					opacity: 1;
					background: #84BD00;
					color: #fff;
					font-size: 24rpx;
					display: flex;
					justify-content: center;
					align-items: center;
				}
			}
		}
	}

	.empty-state {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		margin-top: 106rpx;
	}
</style>